package com.aaa.第二遍;


import java.lang.reflect.Field;

/**
 * @author 荆豪峰
 * @version 1.0
 */
public class d3 {
    public static void main(String[] args) throws Exception {
        Class bbClass = bb.class;
        Object bb = bbClass.newInstance();
        System.out.println("bb = " + bb);
        Field name = bbClass.getDeclaredField("name");
        name.set(bb,"gg");
        System.out.println(bb);
        Object o = name.get(bb);
        System.out.println("o = " + o);


        Field age = bbClass.getDeclaredField("age");
        age.setAccessible(true);
        age.set(bb,18);
        System.out.println(bb);

        Object o1 = age.get(bb);
        System.out.println("o1 = " + o1);
    }
}
class aa{
    public String address;
    private String sex;
}
class bb extends aa {
    public String name;
    private Integer age;

    @Override
    public String toString() {
        return "Teacher{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}